package com.example.xcService.pojo.rabbitmq;

import com.example.entity.AgentDeduction;
import com.example.entity.AgentOrder;
import com.example.service.IAgentDeductionService;
import com.example.xcService.pojo.tool.OrderTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
@RabbitListener(queues = {"refund.deduction.queue"} ,containerFactory = "listenerContainerFactory" ,concurrency = "10-50")
@Slf4j
public class DeductionFanoutConsumer {
    @Autowired
    OrderTool orderTool;

    @Autowired
    IAgentDeductionService deductionService;

    @RabbitHandler
    @Async
    public  void SubmitOrder(String deductionId){
        try{
            AgentDeduction deduction=deductionService.getById(deductionId);
            orderTool.Deduction(deduction);
        }catch (Exception ex){
            log.error("扣款消息队列出错"+deductionId,ex);
        }
    }
}
